C
C     ..................................................................
C
C        SUBROUTINE PSUB
C
C        PURPOSE
C           SUBTRACT ONE POLYNOMIAL FROM ANOTHER
C
C        USAGE
C           CALL PSUB(Z,IDIMZ,X,IDIMX,Y,IDIMY)
C
C        DESCRIPTION OF PARAMETERS
C           Z     - VECTOR OF RESULTANT COEFFICIENTS, ORDERED FROM
C                   SMALLEST TO LARGEST POWER
C           IDIMZ - DIMENSION OF Z (CALCULATED)
C           X     - VECTOR OF COEFFICIENTS FOR FIRST POLYNOMIAL, ORDERED
C                   FROM SMALLEST TO LARGEST POWER
C           IDIMX - DIMENSION OF X (DEGREE IS IDIMX-1)
C           Y     - VECTOR OF COEFFICIENTS FOR SECOND POLYNOMIAL,
C                   ORDERED FROM SMALLEST TO LARGEST POWER
C           IDIMY - DIMENSION OF Y (DEGREE IS IDIMY-1)
C
C        REMARKS
C           VECTOR Z MAY BE IN SAME LOCATION AS EITHER VECTOR X OR
C           VECTOR Y ONLY IF THE DIMENSION OF THAT VECTOR IS NOT LESS
C           THAN THE OTHER INPUT VECTOR
C           THE RESULTANT POLYNOMIAL MAY HAVE TRAILING ZERO COEFFICIENTS
C
C        SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C           NONE
C
C        METHOD
C           DIMENSION OF RESULTANT VECTOR IDIMZ IS CALCULATED AS THE
C           LARGER OF THE TWO INPUT VECTOR DIMENSIONS. COEFFICIENTS IN
C           VECTOR Y ARE THEN SUBTRACTED FROM CORRESPONDING COEFFICIENTS
C           IN VECTOR X.
C
C     ..................................................................
C
      SUBROUTINE PSUB(Z,IDIMZ,X,IDIMX,Y,IDIMY)
      DIMENSION Z(1),X(1),Y(1)
C
C     TEST DIMENSIONS OF SUMMANDS
C
      NDIM=IDIMX
      IF (IDIMX-IDIMY) 10,20,20
   10 NDIM=IDIMY
   20 IF (NDIM) 90,90,30
   30 DO 80 I=1,NDIM
      IF (I-IDIMX) 40,40,60
   40 IF (I-IDIMY) 50,50,70
   50 Z(I)=X(I)-Y(I)
      GO TO 80
   60 Z(I)=-Y(I)
      GO TO 80
   70 Z(I)=X(I)
   80 CONTINUE
   90 IDIMZ=NDIM
      RETURN
      END
